package com.bridgeintelligent.tag.webserver.workflow;

import com.bridgeintelligent.tag.constants.ExceptionCodes;

public enum Status {
    WAITTING(2, "待审核"),
    REJECTED(3, "已驳回"),
    PASSED(4, "已通过");

    private int code;
    private String info;

    Status(int code, String info) {
        this.code = code;
        this.info = info;
    }

    public int code() {
        return code;
    }

    public String info() {
        return info;
    }

    public static Status codeOf(int index) {
        for (Status state : values()) {
            if (state.code() == index) {
                return state;
            }
        }
        throw new WorkflowException(ExceptionCodes.WORKFLOW_20001);
    }

    public static void main(String[] args) {
        int state = Status.WAITTING.code();
        String stateInfo = Status.WAITTING.info();
        System.out.println(state);
        System.out.println(stateInfo);
        String s = Status.codeOf(state).info();
        System.out.println(s);
    }

}
